import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Fortaleza here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Fortaleza extends World
{
    private Monster mons1;
    private Monster mons2;
    private Monster mons3;
    private Monster mons4;
    private Monster mons5;
    private Grass grass1;
    private Grass grass2;
    private Grass grass3;
    private Grass grass4;
    private Grass grass5;
    private Heroe heroe;
    private SimpleTimer timer=new SimpleTimer();
    private SimpleTimer timer2=new SimpleTimer();
    private GreenfootImage image;
    private int wave;
    private Activador activador;
    private Mensaje men;
    private PuertaH puerta;
    private Counter monedas;
    private int puntos;

    public Fortaleza()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(800, 600, 1,false); 
        wave=1;
        prepare();
    }

    public void act()
    {
        play();
        endGame();
    }

    public void endGame()
    {
        if(activador.isDestroyed()==true || puerta.isDestroyed()==true)
        {
            heroe.actualizaPuntos();
            removeObjects( getObjects(Actor.class) );
            setBackground("game_over_pistola.jpg");
            Menu menu=new Menu();
            if(Greenfoot.isKeyDown("enter"))
                Greenfoot.setWorld(menu);
        }
    }

    public void play()
    {
        switch(wave)
        {
            case 1: 
            wave1();
            break;
        }
    }

    public void wave1()
    {
        if(timer.millisElapsed()>=2000)
        {
            int x=Greenfoot.getRandomNumber(9);
            if(x==0)
            {
                mons1=new Monster(grass1,5);
                addObject(mons1,200,0);    
            }
            if(x==2)
            {
                mons2=new Monster(grass2,5);
                addObject(mons2,0,400);
            }
            if(x==4)
            {
                mons3=new Monster(grass3,5);
                addObject(mons3,445,0);
            }
            if(x==6)
            {
                mons4=new Monster(grass4,5);
                addObject(mons4,690,0);
            }
            if(x==8)
            {
                mons5=new Monster(grass5,5);
                addObject(mons5,0,505);;
            }
            timer.mark();
        }
    }

    public Heroe getHeroe()
    {
        return heroe;
    }

    public Activador getActivador()
    {
        return activador;
    }

    public PuertaH getPuerta()
    {
        return puerta;
    }

    /**
     * Prepare the world for the start of the program. That is: create the initial
     * objects and add them to the world.
     */
    private void prepare()
    {
        //  mus1=new GreenfootSound("1.mp3"); 
        // mus1.playLoop();
        removeObjects( getObjects(Actor.class) );
        // removeObjects( getObjects(Ayuda.class) );
        setBackground("Hintergrund.png");
        //     Letrero let=new Letrero  ("nivel 1");
        //   addObject(let,300,30);
        grass1=new Grass();    
        grass2=new Grass();       
        grass3=new Grass();       
        grass4=new Grass();       
        grass5=new Grass();    
        heroe = new Heroe(100); 
        activador=new Activador();
        addObject(activador,335,430);
        puerta = new PuertaH(activador);
        addObject(puerta, 683, 575);
        addObject(heroe, 438, 358);
        addObject(grass1,200,150);
        addObject(grass2,145,400);
        addObject(grass3,445,250);
        addObject(grass4,680,250);
        addObject(grass5,540,505);
        Wall1 wall = new Wall1();
        addObject(wall, 264, 312);
        Wall1 wall2 = new Wall1();
        addObject(wall2, 270, 419);
        wall2.setLocation(264, 411);
        Wall1 wall3 = new Wall1();
        addObject(wall3, 271, 517);
        wall3.setLocation(264, 511);
        Wall2 wall22 = new Wall2();
        addObject(wall22, 331, 279);
        wall22.setLocation(324, 272);
        Wall1 wall4 = new Wall1();
        addObject(wall4, 384, 364);
        wall4.setLocation(384, 312);
        Wall2 wall23 = new Wall2();
        addObject(wall23, 431, 377);
        wall23.setLocation(605, 249);
        wall22.setLocation(322, 209);
        wall.setLocation(280, 306);
        wall.setLocation(262, 249);
        wall2.setLocation(262, 348);
        wall4.setLocation(381, 249);
        wall23.setLocation(423, 314);
        wall23.setLocation(421, 309);
        Wall2 wall24 = new Wall2();
        addObject(wall24, 528, 316);
        wall24.setLocation(521, 309);
        wall3.setLocation(262, 446);
        Wall2 wall25 = new Wall2();
        addObject(wall25, 309, 513);
        Wall2 wall26 = new Wall2();
        addObject(wall26, 615, 488);
        wall25.setLocation(302, 506);
        wall26.setLocation(402, 506);
        Wall2 wall27 = new Wall2();
        addObject(wall27, 510, 512);
        wall27.setLocation(501, 507);
        wall27.setLocation(502, 506);
        Wall2 wall28 = new Wall2();
        addObject(wall28, 610, 512);
        wall28.setLocation(601, 506);
        Wall2 wall29 = new Wall2();
        addObject(wall29, 643, 330);
        Wall1 wall5 = new Wall1();
        addObject(wall5, 668, 553);
        wall22.setLocation(339, 167);
        wall.setLocation(264, 200);
        wall22.setLocation(323, 160);
        wall2.setLocation(264, 299);
        wall3.setLocation(264, 398);
        wall25.setLocation(304, 457);
        wall26.setLocation(404, 457);
        wall27.setLocation(504, 457);
        wall28.setLocation(604, 457);
        wall5.setLocation(664, 497);
        wall29.setLocation(621, 309);
        Wall2 wall210 = new Wall2();
        addObject(wall210, 711, 563);
        wall210.setLocation(704, 557);
        Wall1 wall6 = new Wall1();
        addObject(wall6, 751, 504);
        wall6.setLocation(744, 497);
        Wall1 wall7 = new Wall1();
        addObject(wall7, 751, 405);
        wall7.setLocation(744, 399);
        Wall1 wall8 = new Wall1();
        addObject(wall8, 627, 145);
        wall4.setLocation(383, 200);
        wall23.setLocation(423, 259);
        wall23.setLocation(423, 260);
        wall24.setLocation(522, 260);
        wall24.setLocation(523, 260);
        wall29.setLocation(623, 260);
        wall8.setLocation(699, 124);
        wall3.setLocation(179, 402);
        wall.setLocation(144, 200);
        wall2.setLocation(144, 300);
        wall3.setLocation(144, 400);
        wall25.setLocation(184, 460);
        wall26.setLocation(283, 460);
        wall27.setLocation(381, 460);
        wall27.setLocation(384, 460);
        wall27.setLocation(384, 460);
        wall27.setLocation(384, 460);
        wall27.setLocation(384, 460);
        wall27.setLocation(384, 460);
        wall27.setLocation(384, 460);
        wall27.setLocation(384, 460);
        wall27.setLocation(384, 460);
        wall27.setLocation(384, 460);
        wall27.setLocation(384, 460);
        wall27.setLocation(384, 460);
        wall27.setLocation(382, 460);
        wall28.setLocation(481, 460);
        wall5.setLocation(540, 500);
        wall210.setLocation(580, 559);
        Wall2 wall211 = new Wall2();
        addObject(wall211, 688, 565);
        wall211.setLocation(680, 559);
        wall6.setLocation(739, 518);
        wall6.setLocation(739, 519);
        wall7.setLocation(747, 400);
        wall7.setLocation(739, 421);
        wall7.setLocation(739, 419);
        wall8.setLocation(739, 320);
        Wall2 wall212 = new Wall2();
        addObject(wall212, 729, 267);
        wall212.setLocation(699, 260);
        Wall2 wall213 = new Wall2();
        addObject(wall213, 217, 169);
        wall213.setLocation(204, 160);
        Wall2 wall214 = new Wall2();
        addObject(wall214, 269, 167);
        wall214.setLocation(269, 160);
        wall3.setLocation(65, 169);
        wall214.setLocation(292, 57);
        wall213.setLocation(170, 74);
        wall23.setLocation(524, 70);
        wall3.setLocation(383, 219);
        wall24.setLocation(537, 260);
        wall212.setLocation(677, 87);
        wall29.setLocation(577, 260);
        wall29.setLocation(578, 260);
        wall5.setLocation(739, 305);
        wall22.setLocation(324, 160);
        wall214.setLocation(290, 159);
        wall2.setLocation(144, 300);
        Wall1 wall9 = new Wall1();
        addObject(wall9, 151, 344);
        wall9.setLocation(144, 348);
        wall9.setLocation(144, 339);
        wall9.setLocation(144, 328);
        wall9.setLocation(144, 314);
        removeObject(wall213);
        removeObject(wall23);
        removeObject(wall212);
        BoxWeapon boxweapon = new BoxWeapon();
        addObject(boxweapon, 712, 445);
        boxweapon.setLocation(712, 451);
        boxweapon.setLocation(710, 463);
        boxweapon.setLocation(706, 460);
        wall214.setLocation(290, 160);
        wall211.setLocation(597, 328);
        Wall1 wall10 = new Wall1();
        addObject(wall10, 598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(598, 571);
        wall10.setLocation(645, 596);
        wall210.setLocation(575, 549);
        wall10.setLocation(635, 589);
        Wall1 wall11 = new Wall1();
        addObject(wall11, 748, 594);
        wall11.setLocation(739, 587);
        removeObject(wall211);
        boxweapon.setLocation(702, 391);
    }
}